<template>
  <div>
    <van-cell-group>
      <div class="wodehesuanjilu">我的核酸记录</div>
      <!--      <van-list>-->
      <!--        <van-cell v-for="form in list" :key="form.nfid" :title="form.created_time"/>-->
      <!--      </van-list>-->

      <van-cell-group inset>
        <van-cell v-for="form in list" :key="form.nfid" :title="form.created_time" :label="form.info">
          <template #right-icon>
            <div class="red_font" v-if="form.result===1">{{ form.result_ch }}</div>
            <div v-if="form.result===0">{{ form.result_ch }}</div>
          </template>
        </van-cell>
      </van-cell-group>

      <div class="showMore" @click="showMore">查看更多</div>
    </van-cell-group>
    <van-dialog v-model="show" title="核酸记录" show-cancel-button>
      <van-list>
        <van-cell v-for="item in list" :key="item.nfid" :title="item.created_time" :value="item.result"
                  :label="item.info"/>
      </van-list>
    </van-dialog>


    <my-info-editing></my-info-editing>
  </div>
</template>

<script>
import MyInfoEditing from "../views/sec_views/MyInfoEditing.vue";

export default {
  name: "MyFun",
  components: {MyInfoEditing},

  data() {
    return {
      list: [],
      show: false
    }
  },

  methods: {
    showMore() {
      this.show = true
    },


    getFiveForms() {
      this.axios({
        method: "get",
        url: "/nuclein-form/getMyNucleinForm",
      }).then(resp => {
          if (resp) {
            if (resp.data.code == 200) {
              // console.log( resp.data.data)
              var mylist = resp.data.data
              // this.list = resp.data.data
              for (var form of mylist) {
                // console.log(form)
                var date = new Date(form.created_time);
                form.created_time = `${date.getMonth() + 1}月${date.getDate()}日${date.getHours()}时${date.getMinutes()}分`;
                if (form.result === 1)
                  form.result_ch = '阳'
                else if (form.result === 0)
                  form.result_ch = '阴'
                // console.log(typeof form.created_time)
                form.info = form.position + " " + form.hospital
              }
              // console.log(list)
              this.list = mylist
            }
          }
        }
      )
    }
  },

  created() {
    this.getFiveForms()
  }
}
</script>

<style scoped>

.wodehesuanjilu {
  margin-left: 20px;
}

.showMore {
  font-size: small;
  color: #cecbcb;
  margin-left: 20px;
}

.red_font {
  color: red;
  font-weight: bolder;
}

</style>
